module.exports=[54799,(a,b,c)=>{b.exports=a.x("crypto",()=>require("crypto"))},24836,(a,b,c)=>{b.exports=a.x("https",()=>require("https"))},78219,a=>{"use strict";a.i(47784);var{toArray:b,toBase64:c}=a.i(61101).Utils;async function d(a,c,e=6e5){let f=Uint8Array.from(b(a,"utf8")),g=await globalThis.crypto.subtle.importKey("raw",f,{name:"PBKDF2"},!1,["deriveKey"]);return globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:c,iterations:e,hash:"SHA-256"},g,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function e(a,b,e){let f=globalThis.crypto.getRandomValues(new Uint8Array(16)),g=globalThis.crypto.getRandomValues(new Uint8Array(12)),h=await d(b,f,e),i=JSON.stringify({...a,createdAt:a.createdAt||new Date().toISOString()}),j=new TextEncoder().encode(i),k=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:g},h,j),l=new Uint8Array(f.length+g.length+k.byteLength);return l.set(f,0),l.set(g,f.length),l.set(new Uint8Array(k),f.length+g.length),c(Array.from(l))}async function f(a,c,e){let f;try{f=b(a,"base64")}catch(a){throw console.error("Failed to decode base64 string (toArray threw):",a),Error("Decryption failed: Invalid Base64 input.")}if(a.length>0&&0===f.length)throw Error("Decryption failed: Invalid Base64 input (decoded to empty).");let g=Uint8Array.from(f);if(g.length<28)throw Error("Decryption failed: Encrypted data is too short.");let h=g.slice(0,16),i=g.slice(16,28),j=g.slice(28),k="number"==typeof e?[e]:Array.isArray(e)?e:[6e5,1e5],l=null;for(let a of k)try{let b=await d(c,h,a),e=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:i},b,j),f=new TextDecoder().decode(e);try{let a=JSON.parse(f);if("object"==typeof a&&null!==a&&("xprv"in a&&"ids"in a&&"mnemonic"in a||"rootPk"in a&&"ids"in a||"wif"in a&&"id"in a||"ordPk"in a&&"payPk"in a&&"identityPk"in a||"wif"in a&&!("id"in a)&&!("xprv"in a)&&!("rootPk"in a)))return a;throw Error("Invalid backup structure after JSON parse.")}catch(a){if(a instanceof SyntaxError)return{wif:f};throw a}}catch(a){if(l=a,a instanceof DOMException&&"OperationError"===a.name)continue;throw a}if(console.error("All decryption attempts failed. Last error:",l),l&&"OperationError"===l.name)throw Error("Decryption failed: Invalid passphrase or corrupted data across all attempted iteration counts.");throw l||Error("Decryption failed: Invalid passphrase or corrupted data across all attempted iteration counts.")}async function g(a,b,c){if(!(a&&"object"==typeof a&&("xprv"in a&&"string"==typeof a.xprv&&"ids"in a&&"string"==typeof a.ids&&"mnemonic"in a&&"string"==typeof a.mnemonic||"rootPk"in a&&"string"==typeof a.rootPk&&"ids"in a&&"string"==typeof a.ids&&!("xprv"in a)||"wif"in a&&"string"==typeof a.wif&&"id"in a&&"string"==typeof a.id||"wif"in a&&"string"==typeof a.wif&&!("id"in a)&&!("xprv"in a)&&!("rootPk"in a)||"ordPk"in a&&"string"==typeof a.ordPk&&"payPk"in a&&"string"==typeof a.payPk&&"identityPk"in a&&"string"==typeof a.identityPk)))throw Error("Invalid payload: Payload must be an object matching BapMasterBackup, BapMemberBackup, WifBackup, or OneSatBackup structure.");if("string"!=typeof b||0===b.length)throw Error("Invalid passphrase: Passphrase must be a non-empty string.");if(b.length<8)throw Error("Invalid passphrase: Passphrase must be at least 8 characters long.");return e(a,b,c)}async function h(a,b,c){if("string"!=typeof a||0===a.length)throw Error("Invalid encryptedString: Must be a non-empty string.");if("string"!=typeof b||0===b.length)throw Error("Invalid passphrase: Passphrase must be a non-empty string.");return f(a,b,c)}a.s(["DEFAULT_PBKDF2_ITERATIONS",()=>6e5,"LEGACY_PBKDF2_ITERATIONS",()=>1e5,"RECOMMENDED_PBKDF2_ITERATIONS",()=>6e5,"decryptBackup",()=>h,"encryptBackup",()=>g])}];
//# sourceMappingURL=%5Broot-of-the-server%5D__bf4fcd22._.js.map